<?php
$res = '';
if ( $_POST ) {
	$id = trim($_POST['id']);
	if ( $id ) {
		$link = mysql_connect('127.0.0.1', 'root', 'ybs201606') or die ('Not connected : ' . mysql_error());
		
		// make foo the current db
		mysql_select_db('test', $link) or die ('Can\'t use foo : ' . mysql_error());
		$sql = "INSERT INTO `test`.`a_code` (`id`) VALUES ('".$id."')";
		if ( mysql_query($sql) ) {
			$res = '<span style="color:green;">'.$id.' 成功通过。</span>';
		} else {
			$res = '<span style="color:red;">出现重复！请上缴！</span>';
		}
		
		mysql_close($link);
	}
}


?>
<!DOCTYPE HTML><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<html>
<head>
<title>test</title>
</head>
<body>
<form method="post">
<input type="text" style="height:40px;width:50%;" value="" name="id" />
<br />
<input type="submit" value="插入" />
</form>
<?php 
if ( $res )  {
	echo  $res;
}
?>
</body>
</html>